<template>
  <div class="portal">
    <div class="prev-btn prev" @click="prev" v-if="pages > 1 && page.pageNo > 1">
      <a-icon class="prev-btn-icon" type="double-left"/>
    </div>
    <div class="prev-btn next" @click="next" v-if="pages > 1 && page.pageNo < pages">
      <a-icon class="prev-btn-icon" type="double-right"/>
    </div>
    <div class="card-list" ref="content">
      <!--<a-row type="flex" justify="space-around" :gutter="30">-->
        <!--<a-col v-for="(item, index) in portalData" :span="4">-->
          <!--<a-card-->
            <!--class="portal-card"-->
            <!--@click="goSystem(item)"-->
          <!--&gt;-->
            <!--<div class="portal-card-top">-->
              <!--<span class="portal-card-system">{{ item.name }}</span>-->
            <!--</div>-->
            <!--<img :src="item.icon" class="portal-img"/>-->
            <!--<div class="portal-card-info">-->
              <!--<div class="portal-card-description" :title="item.description">{{ item.description }}</div>-->
            <!--</div>-->
          <!--</a-card>-->
        <!--</a-col>-->
      <!--</a-row>-->
      <a-row :gutter="30">
      <a-col v-for="(item, index) in portalData" :span="8">
        <a-card
          class="portal-card"
          @click="goSystem(item)"
        >
          <img :src="item.icon" class="portal-img-2" alt="未设置图片"/>
          <div class="portal-card-content">
            <div class="portal-card-title">{{ item.name }}</div>
            <div class="portal-card-information" :title="item.appName">应用名：{{ item.appName }}</div>
            <div class="portal-card-information" :title="item.path">地址：{{ item.path }}</div>
            <div class="portal-card-information" :title="item.description">描述：{{ item.description }}</div>
          </div>
        </a-card>
      </a-col>
    </a-row>
    </div>
  </div>
</template>

<script>
  import {getAction} from '@/api/manage'
  export default {
    name: 'PortalMoudle',
    data() {
      return {
        portalData: [],
        url: {
          list: "/sys/module/list"
        },
        page: {
          pageNo: 1,
          pageSize: 9
        },
        pages: 0
      }
    },
    props: {
    },
    methods: {
      prev() {
        if (this.page.pageNo > 1 && this.pages > 1) {
          this.page.pageNo--;
          this.loadData()
        }
      },
      next() {
        if (this.page.pageNo < this.pages) {
          this.page.pageNo++;
          this.loadData()
        }
      },
      loadData() {
        getAction(this.url.list, this.page).then((res) => {
          if (res.success) {
            console.log(res.result.records)
            this.portalData = res.result.records;
            this.total = res.result.total;
            this.pages = res.result.pages;
          }
        })
      },
      goSystem(item) {
        this.$emit('clickEvent', item)
      }
    },
    created() {
      this.loadData()
    }
  }
</script>
<style lang="scss" scoped>
  .portal {
    padding: 20px 0;
    min-height: 60vh;
    .prev-btn{
      cursor: pointer;
      width: 3%;
      position: absolute;
      text-align: center;
      .prev-btn-icon{
        font-size: 2rem;
        opacity: 0.5;
        padding-top: 30vh;
      }
    }
    .next{
      right: 0;
    }
    .card-list{
      width: 94%;
      margin: 0 auto;
    }
    .portal-card {
      cursor: pointer;
      width: 100%;
      padding: 0;
      border-color: transparent;
      position: relative;
      margin-bottom: 20px;
      .portal-card-top {
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        background: #5db0fd;
        padding: 10px;
        text-align: center;
        height: 80px;
        .portal-card-system {
          font-size: 1.3rem;
          color: #fff;
        }
      }
      .portal-img {
        width: 80%;
        position: relative;
        top: -30px;
        left: 10%;
      }
      .portal-img-2{
        height: 155px;
        width: 200px;
        padding: 20px;
        display: inline-block;
      }
      .portal-card-content{
        height: 115px;
        position: absolute;
        left: 200px;
        top: 20px;
        padding-right: 10px;
        width: calc(100% - 210px);
        .portal-card-name {
          font-size: 1.2rem;
        }
        .portal-card-information {
          width: 100%;
          opacity: 0.7;
          margin-top: 4px;
          font-size: 0.8rem;
          height: 20px;
          line-height: 20px;
          word-break: break-all;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
      .portal-card-info {
        position: relative;
        top: -15px;
        padding: 0 10%;
        .portal-card-name {
          font-size: 1.2rem;
        }
        .portal-card-description {
          opacity: 0.7;
          margin-top: 4px;
          font-size: 0.8rem;
          height: 20px;
          line-height: 20px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
</style>
<style>
  .portal-card .ant-card-body {
    padding: 0;
    -webkit-box-shadow: #c7c7c7 0px 0px 18px;
    -moz-box-shadow: #c7c7c7 0px 0px 18px;
    box-shadow: #c7c7c7 0px 0px 18px;
  }
  .ant-card-wider-padding .ant-card-body{
    padding: 0 !important;
  }
</style>